home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / IDE / SUBARTIC / RELEASE.ZIP / sub_arctic / anim / continuous_transition.java < prev    next >
Encoding:
Java Source  |  1996-10-04  |  4.0 KB  |  124 lines

  1. package sub_arctic.anim;
  2.  
  3. import sub_arctic.input.event;
  4.  
  5. /**
  6.  * This is a transition for people who want to have a transition
  7.  * which lasts until you specifically remove it. This object <I>never</I>
  8.  * calls the animatable's end_transition function, only start_transition
  9.  * and the transition_step function. This object doesn't use
  10.  * trajectory or a pacing function, it just converts the current time
  11.  * into a Float object and sends that to the animatable.  This object
  12.  * requires a continuous_interval for its time interval so it is sure
  13.  * that you will not pass it an interval which expires.
  14.  *
  15.  * @author Ian Smith
  16.  */
  17. public class continuous_transition extends transition {
  18.  
  19.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  20.  
  21.   /**
  22.    * How often does the user want calls (in milliseconds).
  23.    */
  24.   protected int _freq;
  25.  
  26.   /**
  27.    * Retrieve the frequency of calls to this animatable object.
  28.    * @return int the frequency of calls in milliseconds
  29.    */
  30.   public int frequency() { return _freq;}
  31.  
  32.   /**
  33.    * Set the frequency of calls to this animatable object.
  34.    * @param int f frequency of calls in milliseconds
  35.    */
  36.   public void set_frequency(int f) { _freq=f;}
  37.  
  38.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  39.  
  40.   /**
  41.    * Construct a permanent transition given an animatable object 
  42.    * and a frequency of calls.<p>
  43.    * 
  44.    * @param animatable a the object to animate
  45.    * @param continuous_interval pi
  46.    * @param int freq the frequency of calls in milliseconds
  47.    */
  48.   public continuous_transition(animatable a, continuous_interval pi,int freq) {
  49.     super(a,pi,null);
  50.     _freq=freq;
  51.   }
  52.  
  53.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  54.  
  55.   /**
  56.    * This object is never finished.
  57.    * @return boolean always return false
  58.    */
  59.   public boolean finished() { return false;}
  60.  
  61.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  62.  
  63.   /**
  64.    * Start a transition. 
  65.    * 
  66.    * @param event e the animation event that caused things to get going
  67.    * @param Object user_info the object passed to the animation agent when 
  68.    *                         the animatable joined its focus set
  69.    */
  70.   public void start(event e,Object user_info) {
  71.  
  72.     _last_time=time_interval.now();
  73.  
  74.     /* just get the current time and shove it in */
  75.     target().start_transition(this, null, 0.0, new Float(_last_time),
  76.                   e,user_info);
  77.   }
  78.  
  79.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  80.  
  81.   /**
  82.    * Perform a step... this sends the transition_step message to the
  83.    * interactor.<p>
  84.    * 
  85.    * @param event e the animation event for this step
  86.    * @param Object user_info the object passed to the animation agent when 
  87.    *                         the animatable joined its focus set
  88.    * @param long current_time the time it is "now" for this time step
  89.    */
  90.   public void step(event e, Object user_info, long current_time) {
  91.  
  92.     /* has the frequency passed */
  93.     if (current_time-_last_time>_freq) {
  94.  
  95.       /* it has passed, send the message */
  96.       target().transition_step(this, null, 0.0,new Float(_last_time),
  97.                    0.0, new Float(current_time),
  98.                    e, user_info);
  99.       _last_time=current_time;
  100.  
  101.     }
  102.  
  103.     /* if the time hasn't passed, we ignore this event */
  104.   }
  105.  
  106.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  107. }
  108. /*=========================== COPYRIGHT NOTICE ===========================
  109.  
  110. This file is part of the subArctic user interface toolkit.
  111.  
  112. Copyright (c) 1996 Scott Hudson and Ian Smith
  113. All rights reserved.
  114.  
  115. The subArctic system is freely available for most uses under the terms
  116. and conditions described in 
  117.   http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html 
  118. and appearing in full in the lib/interactor.java source file.
  119.  
  120. The current release and additional information about this software can be 
  121. found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
  122.  
  123. ========================================================================*/
  124.